<?php
/**
 * 
 * ESQuery   v.1.0.0
 * 
 * Coder:    Even Simon <even.simon@gmail.com>
 * Homepage: http://esquery.googlecode.com/
 * 
 */

	require_once("classes/class.debug.php");
	require_once("classes/class.esquery.php");
	require_once("classes/class.mysql.php");

	session_start();
	header("Content-Type: text/javascript");

	if(!$_REQUEST["Function"])
	{
		echo json_encode(array("Error"=>Debug::ERROR_BAD_REQUEST));
		exit;
	}

	$ESQuery = new ESQuery();

	if(Debug::DEBUG_MODE)
	{
		Debug::Message($_SESSION);
	}

	switch($_REQUEST["Function"])
	{
		case ESQuery::FUNC_IS_LOGGED:
			$ESQuery->isLogged();
			break;
		
		case ESQuery::FUNC_LOGIN:
			$ESQuery->login();
			break;
		
		case ESQuery::FUNC_LOGOUT:
			$ESQuery->logout();
			break;
		
		case ESQuery::FUND_GET_DBS:
			$ESQuery->getDBS();
			break;
		
		case ESQuery::FUNC_GET_TABLE_DATA:
			$ESQuery->getTableData($_REQUEST["Database"],$_REQUEST["Table"]);
			break;
		
		case ESQuery::FUNC_GET_BASIC_DATA:
			$ESQuery->getBasicData();
			break;
	}
	
	$ESQuery->printResponse();
?>